#!/usr/bin/env php
<?php

if ($argc != 3) {
    die('Usage: ' . $argv[0] . " [url] [count]\n");
}

$url = $argv[1];
$count = $argv[2];

echo "Performing $count requests to $url (results in ms):\n\n";

for ($i = 0; $i < $count; $i++) {
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    $time = -microtime(true);
    curl_exec($ch);
    $time += microtime(true);
    curl_close($ch);
    echo number_format($time * 1000, 2) . "\n";
    usleep(50);
}